package com.wms.mapper;

import com.github.pagehelper.Page;
import com.wms.dto.GoodsPageQueryDTO;
import com.wms.entity.WmsGoods;
import com.wms.entity.WmsType;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface GoodsMapper {
    /**
     * 分页查询
     * @param goodsPageQueryDTO
     * @return
     */
    Page<WmsGoods> pageQuery(GoodsPageQueryDTO goodsPageQueryDTO);

    /**
     * 新增
     * @param wmsGoods
     */
    void save(WmsGoods wmsGoods);

    /**
     * 修改
     * @param wmsGoods
     */
    void update(WmsGoods wmsGoods);

    /**
     * 批量删除
     * @param ids
     */
    void delete(List<Integer> ids);

    /**
     * 根据id查询
     * @param id
     * @return
     */
    @Select("select * from wms_goods where id = #{id}")
    WmsGoods getById(Long id);

    /**
     * 根据仓库id查询
     * @param id
     * @return
     */
    @Select("select * from wms_goods where storage = #{id}")
    List<WmsGoods> getByStorageId(Long id);

    /**
     * 根据类型id查询
     * @param id
     * @return
     */
    @Select("select * from wms_type where id = #{id}")
    List<WmsType> getByTypeId(Long id);

    @Select("select * from wms_goods")
    List<WmsGoods> getAll();

    /**
     * 根据名称查询
     * @param goodsName
     * @return
     */
    @Select("select * from wms_goods where name = #{goodsName}")
    WmsGoods getByName(String goodsName);
}
